#pragma once
#include <mutex>

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
#include <libswscale/swscale.h>
#include <libavutil/frame.h>
#include <libavdevice/avdevice.h>
}

#include "videostream_core.h"

#define DUMMY_SINK_RECEIVE_BUFFER_SIZE 1000000

class VSFFH264 : public VSFrameQueue{
public:
	VSFFH264() ;
	
	~VSFFH264();
	
	bool Init();

    void DecodeFrame(unsigned char* sPropBytes, int sPropLength, unsigned char* pPropBytes,
                            int pPropLength, uint8_t* frameBuffer, int frameLength, struct timeval frametime);

	int GetDecodeFrame(cv::Mat* frame);

public:
	AVCodec* m_pCodec;
	AVCodecContext* m_pCodecContext;
	AVFrame* m_uFrame;
	AVFrame* m_uFrameBGR;
	uint8_t* m_uOBuffer;
	AVFormatContext* m_pOFmtCtx;
	SwsContext* m_pSwsContext;
	AVPicture* m_pAVPicture;
	unsigned char* out_bufferRGB;
	int m_nVideoIndex;
	int m_nWidth;
	int m_nHeight;
};


